//--------------------------------------------------------------------------------------
// File: Tutorial04.fx
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//--------------------------------------------------------------------------------------

struct Light
{
	float4 direction;
	float4 colour;
	float4 ambient;
	float4 position;
	float4 attenuation;
	float2 pad1;
	float range;
	int enabled;
};

//--------------------------------------------------------------------------------------
// Constant Buffer Variables
//--------------------------------------------------------------------------------------
cbuffer ConstantBuffer : register( b0 )
{
	float4 TEST;
	matrix World;
	matrix View;
	matrix Projection;
	matrix LightViewMatrix;
	matrix LightProjMatrix;
	Light light[3];
	float4 OutputColour;
	float2 TexturePositionOne;
	float2 TexturePositionTwo;
	float3 CameraPosition;
}
//--------------------------------------------------------------------------------------
struct VS_INPUT // = PS_INPUT
{
    float4 Pos : POSITION;
    float2 TexCoord : TEXCOORD0;
	float3 Normal : NORMAL0;
	float3 Tangent : TANGENT;
	float3 Binormal : BINORMAL;
};

struct PS_INPUT
{
	float4 Pos : SV_POSITION;
	float2 TexCoord : TEXCOORD0;
	float3 Normal : NORMAL0;
	float3 Tangent : TANGENT;
	float3 Binormal : BINORMAL;
	float4 LightViewPosition : TEXCOORD1;
};


Texture2D ObjTexture : register( t0 );
Texture2D ObjTexture2 : register( t1 );
SamplerState ObjSamplerState : register( s0 );

//--------------------------------------------------------------------------------------
// Vertex Shader
//--------------------------------------------------------------------------------------
PS_INPUT VS(VS_INPUT input)
{
    PS_INPUT output = (PS_INPUT)0;
	
    output.Pos = mul( input.Pos, World );
    output.Pos = mul( output.Pos, View );
    output.Pos = mul( output.Pos, Projection );
	
	output.Normal = mul(input.Normal, World);
	
	output.TexCoord = input.TexCoord;

	output.LightViewPosition = mul(input.Pos, World);
	output.LightViewPosition = mul(output.LightViewPosition, LightViewMatrix);
	output.LightViewPosition = mul(output.LightViewPosition, LightProjMatrix);

    return output;
}


//--------------------------------------------------------------------------------------
// Pixel Shader
//--------------------------------------------------------------------------------------
float4 PS(PS_INPUT input) : SV_Target
{
	return OutputColour;
	return float4(0.0f, 0.5f, 0.0f, 0.5f);
	return input.Pos.z;
}

float4 PSSolid( PS_INPUT input) : SV_Target
{
    return float4(0, 0, 0, 0);
}
